<?php
/**
 * Created by Zhy
 * User: Zhy
 * Date: 2018/6/25
 * Time: 18:26
 */

namespace app\common\model;


use think\Model;

class Notice extends Model
{
    /**
     * 根据条件查询系统消息
     * @param $where 查询条件
     * @return false|\PDOStatement|string|\think\Collection
     */
    public function getNoticeLists($where, $pageSize){
        $lists = $this
            ->where($where)
            ->order('n_id desc')
            ->paginate($pageSize);
        return $lists;
    }
    
    /**
     * 添加系统信息
     * @param $data 添加的数据
     * @return false|int
     */
    public function createSystemMessage($data){
        $res = $this->save($data);
        return $res;
    }
    
    /**
     * 根据id修改数据
     * @param $n_id  被修改记录的id
     * @param $data  修改的数据
     * @return $this
     */
    public function updateSystemMessage($n_id, $data){
        $res = $this->where('n_id', $n_id)->update($data);
        return $res;
    }
    
    /**
     * 根据系消息id，获取一条记录
     * @param $n_id
     * @return array|false|\PDOStatement|string|Model
     */
    public function getOneInfo($n_id){
        $res = $this->where('n_id', $n_id)->find();
        return $res;
    }
}